package com.cskaoyan.service;

import com.cskaoyan.bean.Collect;
import com.cskaoyan.bean.CollectExample;
import com.cskaoyan.mapper.CollectMapper;
import com.cskaoyan.vo.CollectVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2021/4/9 - 18:35
 */
@Service
public class CollectServiceImpl implements CollectService {

    @Autowired
    CollectMapper collectMapper;
    @Override
    public CollectVo qurey(Integer page, Integer limit, String sort, String order) {

        PageHelper.startPage(page,limit);

        CollectExample collectExample = new CollectExample();
        List<Collect> collects = collectMapper.selectByExample(collectExample);

        PageInfo<Collect> collectPageInfo = new PageInfo<>();
        long total = collectPageInfo.getTotal();

        CollectVo collectVo = new CollectVo();
        collectVo.setItems(collects);
        collectVo.setTotal(total);

        return collectVo;
    }
}
